package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级管理")
@Slf4j
public class NursingLevelController extends BaseController {
    @Autowired
    NursingLevelService nursingLevelService;

    /**
     * 分页查询护理等级信息
     *
     * @return 分页结果
     */
    @GetMapping("/listByPage")
    @ApiOperation(value = "分页查询护理等级信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "姓名", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态", required = false, dataType = "int", paramType = "query"),
    })
    public ResponseResult<PageResponse<NursingLevelVo>> listByPage(Integer pageNum,
                                                                   Integer pageSize,
                                                                   String name,
                                                                   Integer status
    ) {
        PageResponse<NursingLevelVo> pageInfo = nursingLevelService.selectByPage(pageNum, pageSize,name, status);
        return success(pageInfo);
    }

    //新增护理等级
    @PostMapping("/insert")
    @ApiOperation(value = "新增护理等级")
    public ResponseResult insert(@RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.insert(nursingLevelDto);
        return success();
    }

    //删除护理等级
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除护理等级")
    public ResponseResult delete(@PathVariable Long id) {
        nursingLevelService.delete(id);
        return success();
    }

    //根据id查询护理等级信息
    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询护理等级信息")
    public ResponseResult<NursingLevelVo> getById(@PathVariable Long id) {
        NursingLevelVo nursingLevelVo = nursingLevelService.getById(id);
        return success(nursingLevelVo);
    }

    //修改护理等级信息
    @PutMapping("/update")
    @ApiOperation(value = "修改护理等级信息")
    public ResponseResult update(@RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.upDateNursingLevel(nursingLevelDto);
        return success();
    }

    //启用禁用
    @PutMapping("/{id}/status/{status}")
    @ApiOperation(value = "修改护理等级状态")
    public ResponseResult updateStatus(@PathVariable Long id, @PathVariable Integer status) {
        nursingLevelService.updateStatus(id, status);
        return success();
    }

    //查询所有护理等级信息
    @GetMapping("/listAll")
    @ApiOperation(value = "查询所有护理等级信息")
    public ResponseResult<List<NursingLevelVo>> getAll() {
        List<NursingLevelVo> nursingLevelVos = nursingLevelService.getAll();
        return success(nursingLevelVos);
    }

}
